(function() {
    var shareImg = document.getElementById('shareImg').innerText;
    var shareTitle = document.getElementById('shareTitle').innerText;

    //改变copyRight的图表颜色。
    // nie.config.copyRight.setGray();


    nie.use(["nie.util.shareV3"], function() {
        //share
        var Share = nie.util.share({
            fat: "#share",
            type: 1,
            defShow: [23, 22, 5, 2, 1, 4],
            title: shareTitle,
            img: shareImg,
            content: null
        });

    });


    $('.tab').bind('click',function(e){
        var $target = $(e.target);
        if($target.hasClass('chosen')){
            return;
        }else {
            $target.addClass('chosen').siblings().removeClass('chosen');
            var index = $target.index();
            $target.parent('ul').siblings('ul.ranking-list').hide().eq(index).show();
        }

    });

    var count = 1;
    $('#next').bind('click',function(e){
        e.preventDefault();
        var $target = $(e.target);
        var $beautyList = $('#beautyList');
        var marginLeft = parseInt($beautyList.css('margin-left'));
        if($target.hasClass('disabled')){
            return;
        }else {
            count ++;
            if(count === 4){
                $target.addClass('disabled');
                $beautyList.animate({
                    'margin-left': '-2530px'
                },800);
            }else if(count === 2) {
                $beautyList.animate({
                    'margin-left': '-920px'
                },800);
                $('#pre').removeClass('disabled');

            }else{
                $beautyList.animate({
                    'margin-left': '-=920px'
                },800);
            }

        }


    });
    $('#pre').bind('click',function(e){
        e.preventDefault();
        var $target = $(e.target);
        var $beautyList = $('#beautyList');
        var marginLeft = parseInt($beautyList.css('margin-left'));
        if($target.hasClass('disabled')){
            return;
        }else {
            count--;
            if(count === 1){
                $target.addClass('disabled');
                $beautyList.animate({
                    'margin-left': '0px'
                },800);
            }else if(count === 3) {
                $beautyList.animate({
                    'margin-left': '-1840px'
                },800);
                $('#next').removeClass('disabled');

            }else {
                $beautyList.animate({
                    'margin-left': '+=920px'
                },800);
            }

        }

    });

    $('#beautyList li').bind('click',function(e){
        var $target = $(this);
        var src= $target.find('img').attr('src');
        var name = $target.find('.item-des-name').text();
        var count = $target.find('.item-des-detail').text();

        $('.mask').show();
        $('#popPic').attr('src',src);
        $('#popName').text(name);
        $('#popDetail').text(count);
        $('.pop').show();

    });

    $('.pop-close').bind('click', function(e){
        e.preventDefault();
        $('.mask').hide();
        $('.pop').hide();
    })



})();